<template>
	<view :class="[BackGround]" :style="[{'font-weight':Style,'font-family':Font,height:100 + '%',minHeight:height + 'px'}]">
		<cu-custom bgColor="bg-gradual-blue" isBack="true">
			<view slot="backText">返回</view>
			<view slot="content">类型录入</view>
		</cu-custom>
		<view :class="['margin-xs radius shadow shadow-lg bg-white' ,BackGroundBox]" v-if="isShow">
			<form @submit="formSubmit" @reset="formReset">
				<view class="cu-form-group">
					<view class="title">机器编号</view>
					<input type="text" name="LCODE" placeholder="请手动输入"/>
				</view>
				<view class="cu-form-group">
					<view class="title">机器名称</view>
					<input type="text" name="LNAME" placeholder="请手动输入" />
				</view>
				<view class="cu-form-group">
					<view class="title">是否有效</view>
					<switch @change="SwitchA" name="lisused" :class="switchA?'checked':''" :checked="switchA?true:false"></switch>
				</view>
				<view class="cu-form-group">
					<view class="title">备注</view>
					<input type="text" name="LREMARK" :adjust-position="false" v-model="LREMARK" @focus="focus"/>
				</view>
				<button-father :Position="'tb-fa-fixed'">
					<button class="cu-btn bg-gradual-blue  lg shadow tb-flex cu-btn-new" form-type="submit">确认</button>
				</button-father>
			</form>
		</view>
		<!--输入框组件-->
		<zyt-input tui-top-dropdown="tui-top-dropdown" bgcolor="rgba(76, 76, 76, 0.95)" :show="menuShow" :height="0"
		 @close="closeMenu" :zvalue="LREMARK" @zblur="zblur">
		</zyt-input>
		<!---输入框组件-->
	</view>
</template>

<script>
	import {
		addForm
	} from "@/service/insert.js"
	import ButtonFather from '@/colorui/components/ButtonFather.vue'
	import {
		mapGetters
	} from 'vuex'
	export default {
		data() {
			return {
				isShow:true,
				height:this.screenHeight,
				switchA:true,
				picker1: [{
					LNAME: '型号一'
				}, {
					LNAME: '型号二'
				}, {
					LNAME: '型号三'
				}],
				index1:0,
				picker2: [{
					LNAME: '型号一'
				}, {
					LNAME: '型号二'
				}, {
					LNAME: '型号三'
				}],
				index2:0,
				date: global.dateright,
				LMAKEOPID:global.userinfo.lusername,
				LREMARK:"",
				menuShow:null
			}
		},
		computed: {
			...mapGetters([
				'Style','Font','BackGround','BackGroundBox'
			]),

		},
		components: {
			ButtonFather
		},
		methods: {
			PickerChange1(e) {
				this.index1 = e.detail.value
			},
			PickerChange2(e) {
				this.index2 = e.detail.value
			},
			SwitchA(e) {
				this.switchA = e.detail.value
			},
			focus(e) {
				this.menuShow = true
				this.LREMARK = e.detail.value
			},
			openMenu() {
				this.menuShow = false
			},
			zblur(value) {
				console.log(value);
				this.LREMARK = value
			},
			closeMenu() {
				this.menuShow = false
			},
			formSubmit(e) {
				console.log(e.detail.value);
				let data = e.detail.value
				addForm(data.LCODE,data.LNAME,data.lisused,this.LREMARK,196,false).then(res => {
					if(res.code == 1) {
						uni.navigateBack({
							delta:1
						})
						uni.showToast({
							title:'添加成功',
							icon:'success',
							duration:2000
						})
					} else {
						uni.showToast({
							title:'添加失败',
							icon:'none'
						})
					}
				})
			}
		}
	}
</script>

<style>
	page {
		background-color: whitesmoke;
	}
</style>
